#ifndef LISTENER_H
#define LISTENER_H
extern "C" {
#include <event2/event.h>
#include <event.h>
#include <event2/listener.h>
};
#include "Connection.h"
#include <string>
class Handler;
class Service;
class ListenerHandler;
struct bufferevent;
struct evconnlistener;
class Listener
{
public:
	Listener(std::string ip, int port, Service* service, ListenerHandler* handler);
	bool startListen();
	void stopListen();
	static void onAccept(struct evconnlistener *listener, evutil_socket_t fd, struct sockaddr* addr, int len, void *ptr);
private:
	std::string m_ip;
	int m_port;
	Service* m_service;
	evconnlistener* m_listener;
	evutil_socket_t m_listenFd;
	ListenerHandler* m_handler;
};
#endif // LISTENER_H

